<?php
header("Content-Type: text/plain;charset=utf-8");
require_once('dbconn.php');

class RespDao{
    //添加建言回复
    public function insert($content,$responseFor,$date){
        //将suggestion的数据存入数据库
        $sql = "insert into resp(resp_content,resp_suggid,resp_date) values ('".$content."','".$responseFor."','".$date."')";
        //echo $sql;
        $conn = new dbconn();
        $link = $conn->connection();
        $query = mysqli_query($link,$sql) ;
        return $query;
    }

    //删除某条回复
    public function delete($respId){
        $sql = "delete from resp where resp_id =".$respId;

        $conn = new dbconn();
        $link = $conn->connection();
        $query = mysqli_query($link,$sql) ;
        return $query;
    }

    //删除某条建言的回复
    public function deleteBySugg($suggId){
        $sql = "delete from resp where resp_suggid =".$suggId;

        $conn = new dbconn();
        $link = $conn->connection();
        $query = mysqli_query($link,$sql) ;
        return $query;
    }

    //查询所有建言
    public function selectAll(){
        $sql = "select * from resp";

        $conn = new dbconn();
        $link = $conn->connection();
        $query = mysqli_query($link,$sql) ;
        return $query;
    }

    //通过suggid查询单条建言回复
    public function selectById($suggId){
        $sql = "select * from resp where resp_suggid=".$suggId;

        $conn = new dbconn();
        $link = $conn->connection();
        $query = mysqli_query($link,$sql) ;
        return $query;
    }
}